package com.szxy.hotel.mapper;

import com.szxy.hotel.entity.Consume;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ConsumeMapper {

    @Insert("insert into consume (consume_roomid,consume_name,consume_price,consume_number,consume_time,consume_year,consume_month,consume_day,consume_username) " +
            "values(#{consume.consumeRoomid},#{consume.consumeName},#{consume.consumePrice},#{consume.consumeNumber},#{consume.consumeTime},#{consume.consumeYear}," +
            "#{consume.consumeMonth},#{consume.consumeDay},#{consume.consumeUsername})")
    @ResultMap("ConsumeResultMap")
    int insertConsume(@Param("consume") Consume consume);

    @Select("select c.consume_roomid cid,c.consume_name cname,c.consume_price cprice,c.consume_number cnumber,c.consume_time ctime,v.vip_discount vdiscount,v.vip_dis_double vdisdouble from consume c,vip v where c.consume_username=v.vip_name limit #{start},#{size}")
    @ResultMap("ConsumeVipResultMap")
    List<Consume> findByPage(@Param("start") int start,@Param("size") int size);

    @Select("select c.consume_roomid cid,c.consume_name cname,c.consume_price cprice,c.consume_number cnumber,c.consume_time ctime,v.vip_discount vdiscount,v.vip_dis_double vdisdouble from consume c,vip v where c.consume_username=v.vip_name")
    @ResultMap("ConsumeVipResultMap")
    List<Consume> selectCount();

    @Select("select c.consume_roomid cid,c.consume_name cname,c.consume_price cprice,c.consume_number cnumber,v.vip_discount vdiscount,v.vip_dis_double vdisdouble from consume c,vip v where c.consume_username=v.vip_name and c.consume_roomid=#{selectroomid} limit #{start},#{size}")
    @ResultMap("ConsumeVipResultMap")
    List<Consume> findByPage1(@Param("start") int start,@Param("size") int size,@Param("selectroomid") String selectroomid);

    @Select("select c.consume_roomid cid,c.consume_name cname,c.consume_price cprice,c.consume_number cnumber,v.vip_discount vdiscount,v.vip_dis_double vdisdouble from consume c,vip v where c.consume_username=v.vip_name and c.consume_roomid=#{selectroomid}")
    @ResultMap("ConsumeVipResultMap")
    List<Consume> selectCount1(@Param("selectroomid") String selectroomid);

    @Select("select c.consume_roomid cid,c.consume_name cname,c.consume_price cprice,c.consume_number cnumber,v.vip_discount vdiscount,v.vip_dis_double vdisdouble from consume c,vip v where c.consume_username=v.vip_name and c.consume_time=#{consumeDate} limit #{start},#{size}")
    @ResultMap("ConsumeVipResultMap")
    List<Consume> findByPageDate(@Param("start") int start,@Param("size") int size,@Param("consumeDate") String consumeDate);

    @Select("select c.consume_roomid cid,c.consume_name cname,c.consume_price cprice,c.consume_number cnumber,v.vip_discount vdiscount,v.vip_dis_double vdisdouble from consume c,vip v where c.consume_username=v.vip_name and c.consume_time=#{consumeDate}")
    @ResultMap("ConsumeVipResultMap")
    List<Consume> selectCountDate(@Param("consumeDate") String consumeDate);

    @Select("select c.consume_roomid cid,c.consume_name cname,c.consume_price cprice,c.consume_number cnumber,v.vip_discount vdiscount,v.vip_dis_double vdisdouble from consume c,vip v where c.consume_username=v.vip_name and c.consume_year=#{my} and c.consume_month=#{mm} limit #{start},#{size}")
    @ResultMap("ConsumeVipResultMap")
    List<Consume> findByPageMonth(@Param("start") int start,@Param("size") int size,@Param("my") String my,@Param("mm") String mm);

    @Select("select c.consume_roomid cid,c.consume_name cname,c.consume_price cprice,c.consume_number cnumber,v.vip_discount vdiscount,v.vip_dis_double vdisdouble from consume c,vip v where c.consume_username=v.vip_name and c.consume_year=#{my} and c.consume_month=#{mm}")
    @ResultMap("ConsumeVipResultMap")
    List<Consume> selectCountMonth(@Param("my") String my,@Param("mm") String mm);

    @Select("select c.consume_roomid cid,c.consume_name cname,c.consume_price cprice,c.consume_number cnumber,v.vip_discount vdiscount,v.vip_dis_double vdisdouble from consume c,vip v where c.consume_username=v.vip_name and c.consume_year=#{yy} limit #{start},#{size}")
    @ResultMap("ConsumeVipResultMap")
    List<Consume> findByPageYear(@Param("start") int start,@Param("size") int size,@Param("yy") String yy);

    @Select("select c.consume_roomid cid,c.consume_name cname,c.consume_price cprice,c.consume_number cnumber,v.vip_discount vdiscount,v.vip_dis_double vdisdouble from consume c,vip v where c.consume_username=v.vip_name and c.consume_year=#{yy}")
    @ResultMap("ConsumeVipResultMap")
    List<Consume> selectCountYear(@Param("yy") String yy);
}